const fs=require('fs')
const path=require('path')

function delDir(filePath){
    if(fs.existsSync(filePath)){
        var files=fs.readdirSync(filePath)
        for(var i=0;i<files.length;i++){
            var childPath=filePath+'/'+files[i]
            var fileObj=fs.statSync(childPath);
            if(fileObj.isFile()){
                fs.unlinkSync(childPath);
            }
            else if(fileObj.isDirectory()){
                delDir(childPath)
            }
        }
        fs.rmdirSync(filePath)
    }
    else{
        console.log('文件路径不存在')
    }
}

var argv=process.argv[2]
var filePath=path.join(__dirname,'/'+argv)
delDir(filePath)